Skip to content

fix(codegen-base): record JVM template and docs output in the hash manifest - #629

Merged
dmealing merged 6 commits into
mainfrom
fm/mo-130-lane-jvm-3
Nov 21, 2026
Merged

dmealing merged 6 commits into
mainfrom
fm/mo-130-lane-jvm-3

Conversation

@dmealing

@dmealing dmealing commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

What Changed

  • Template, documentation and META-INF/services output on Java and Kotlin now goes through GeneratedFileWriter.writeUnmarked, so each file is recorded in the hash manifest. Unchanged bytes are not rewritten, a hand edit is refused by name under handEdits: keep, and the orphan sweep deletes an untouched file the template no longer renders. A file at such a path with no manifest record is adopted on the first run, since these outputs cannot carry a GENERATED marker. The documentation generators also no longer pre-create empty files.
  • mvn metaobjects:eject -Dforce=true compares before writing: a file, or the codegen/pom.xml, that already holds the reference bytes is reported IDENTICAL and left untouched. metaobjects:fmt, metaobjects:init and the codegen fingerprint write through writeIfChanged. A new GeneratorWritePathTest runs every registered Java and Kotlin generator and fails if a file bypasses the writer or a second run rewrites bytes.
  • The int-backed enum array description is consolidated into docs/features/field-types.md (#int-backed-enum-arrays), with a per-port table. The Java, Kotlin, C#, Python and codegen docs now link there instead of repeating it. The hand-edit rule is likewise stated once in docs/features/own-your-codegen.md.

Test step: two lanes were stopped by the out-of-memory killer

The Test step passed with an approved override. scripts/ci-local.sh --affected --strict-toolchains ran every lane, because docs/* changed. The Java reactor, Python, Rust, TypeScript build + typecheck, TypeScript unit suites and the mutation completeness gate were green. Two lanes were killed by the machine's out-of-memory killer (earlyoom SIGTERM) under load from other work on the machine. Neither lane failed a test:

  • C# conformance: all 1668 tests passed, then the test host process was killed.
  • TypeScript conformance: the typed-create-compile.test.ts worker was killed.

Nothing in this diff reaches C# or TypeScript code. The only TypeScript change is a .gitignore rule plus deleting that killed test's leftover temp directory. The comparison run on the base commit was also killed, so the gate could not attribute failures.

This change took one no-mistakes gate run.

Validation

Risk Assessment

✅ Low: The change adds a manifest-aware writeUnmarked path and a behavioral gate (asserting manifest records, per-generator output and zero rewrites on a second run). Prior rounds' findings are fixed, and the eject compare-before-write and docs consolidation trace correctly.

Testing

Drove three JVM scenarios and ran the full Java reactor suite. Template and docs output now joins the hash manifest: unchanged output is not rewritten and a hand edit is refused by name (live driver on the real GeneratedFileWriter). The write-path gate catches both kinds of bypass, shown by an adversarial live driver. The eject goal leaves an identical copy and pom unwritten under -Dforce=true, shown by MetaDataEjectMojoTest, which runs the real mojo in-process. Focused tests pass 57/57. Full mvn -o test reactor BUILD SUCCESS, 0 failures, though Testcontainers integration-tests are outside this reactor run. The docs consolidation has no runtime surface and was not driven. Overall: pass.

  • Live validation: ✅ go - 4 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Live: template/docs output is recorded in the hash manifest, an unchanged rerun does not rewrite it, and a hand edit is refused by name (disposable project, real GeneratedFileWriter, handEdits=keep) ✅ pass live jvm-template-output-manifest-live.txt: WRITTEN with manifest record out/Entity.txt; identical rerun UNCHANGED, mtime preserved; hand-edited rerun REFUSED with warning, disk keeps HAND EDIT
Adversarial: the write-path gate detects a generator that bypasses GeneratedFileWriter (plain Files.writeString) and one that uses writeIfChanged (no manifest record) ✅ pass live jvm-gate-bypass-adversary-live.txt: plain write absent from emittedPaths and from manifest; writeIfChanged output present in emittedPaths but absent from manifest, so the gate's disk-vs-emitted and ma…
Every registered Java and Kotlin generator writes through GeneratedFileWriter, and a second run over an unchanged tree rewrites nothing (fitness corpus) ✅ pass live GeneratorWritePathTest 1/1 pass in jvm-focused-tests-mvn.log; included in jvm-reactor-mvn-test.log
Eject goal with -Dforce=true leaves an identical copy and an identical pom unwritten (mtime preserved), and still replaces an edited copy ✅ pass live MetaDataEjectMojoTest 20/20 pass, including forceLeavesAnIdenticalCopyAndPomUnwritten and forceReplacesAnEditedCopyWithTheReference, in jvm-focused-tests-mvn.log
Docs consolidation: int-backed enum-array text owned by docs/features/field-types.md, port pages point to it ⏸️ untested no Documentation-only change with no runtime behavior; a link and content check is not a live scenario. Covered by the review round, not by this run.
Evidence: Live: template/docs output manifest, unchanged rewrite, hand-edit refusal
STEP1 first write (unmarked template output, no manifest yet)
  outcome=WRITTEN
  manifest has record for out/Entity.txt = true
  disk=alpha\n
STEP2 identical rerun must not rewrite
  outcome=UNCHANGED
  mtime untouched=true
STEP3 hand edit, rerun with handEdits=keep must refuse by name
13:25:56.388 WARN  c.m.g.util.GeneratedFileWriter - refusing to overwrite $DEV_SCRATCH/wp-driver/proj/out/Entity.txt — it was edited since metaobjects generated it, so it is treated as hand-edited and was left untouched (handEdits: keep). Move your edits into a file of your own, delete this file and re-run to accept the generated version, or set this generator's <handEdits> to 'overwrite' to have it replace hand edits automatically.
  outcome=REFUSED
  disk after=alpha\nHAND EDIT\n
Evidence: Live adversarial: write-path gate bypass detection
emitted contains ViaWriteIfChanged=true
emitted contains PlainWrite=false
manifest record ViaWriteIfChanged=false
manifest record PlainWrite=false
Evidence: Focused JVM tests (Maven)
13:24:39.888 WARN  c.m.g.util.GeneratedFileWriter - refusing to overwrite <tmp>/X.java — it carries no 'GENERATED' marker, so it is treated as hand-written and was left untouched. If you want the generated version, move or delete this file and re-run.
13:24:39.893 WARN  c.m.g.util.GeneratedFileWriter - refusing to overwrite <tmp>/X.java — it carries no 'GENERATED' marker, so it is treated as hand-written and was left untouched. If you want the generated version, move or delete this file and re-run.
13:24:39.893 WARN  c.m.g.util.GeneratedFileWriter - refusing to overwrite <tmp>/X.java — it carries no 'GENERATED' marker, so it is treated as hand-written and was left untouched. If you want the generated version, move or delete this file and re-run.
13:24:39.899 WARN  c.m.g.util.GeneratedFileWriter - refusing to overwrite <tmp>/gen/X.java — it carries no 'GENERATED' marker, so it is treated as hand-written and was left untouched. If you want the generated version, move or delete this file and re-run.
13:24:39.902 WARN  c.m.g.util.GeneratedFileWriter - refusing to overwrite <tmp>/docs/customer.md — it was edited since metaobjects generated it, so it is treated as hand-edited and was left untouched (handEdits: keep). Move your edits into a file of your own, delete this file and re-run to accept the generated version, or set this generator's <handEdits> to 'overwrite' to have it replace hand edits automatically.
13:24:39.903 WARN  c.m.g.util.GeneratedFileWriter - refusing to overwrite <tmp>/X.java — it carries no 'GENERATED' marker, so it is treated as hand-written and was left untouched. If you want the generated version, move or delete this file and re-run.
13:24:39.906 WARN  c.m.g.util.GeneratedFileWriter - refusing to overwrite <tmp>/X.java — it carries no 'GENERATED' marker, so it is treated as hand-written and was left untouched. If you want the generated version, move or delete this file and re-run.
13:24:39.913 WARN  c.m.g.util.GeneratedFileWriter - refusing to overwrite <tmp>/Settings.java — it carries no 'GENERATED' marker, so it is treated as hand-written and was left untouched. If you want the generated version, move or delete this file and re-run.
13:24:39.913 WARN  c.m.g.util.GeneratedFileWriter - refusing to overwrite <tmp>/Settings.java — it carries no 'GENERATED' marker, so it is treated as hand-written and was left untouched. If you want the generated version, move or delete this file and re-run.
13:24:39.932 WARN  c.m.g.util.GeneratedFileWriter - refusing to overwrite <tmp>/gen/X.java — it carries no 'GENERATED' marker, so it is treated as hand-written and was left untouched. If you want the generated version, move or delete this file and re-run.
13:24:39.934 WARN  c.m.g.util.GeneratedFileWriter - refusing to overwrite <tmp>/Settings.java — it carries no 'GENERATED' marker, so it is treated as hand-written and was left untouched. If you want the generated version, move or delete this file and re-run.
13:24:39.943 WARN  c.m.g.util.GeneratedFileWriter - overwrote hand-edited <tmp>/gen/X.java (handEdits: overwrite)
13:24:39.946 WARN  c.m.g.util.GeneratedFileWriter - refusing to overwrite <tmp>/gen/X.java — it was edited since metaobjects generated it, so it is treated as hand-edited and was left untouched (handEdits: keep). Move your edits into a file of your own, delete this file and re-run to accept the generated version, or set this generator's <handEdits> to 'overwrite' to have it replace hand edits automatically.
[info] Ejected "api-docs" -> <tmp>/adopter-app/codegen/src/main/java/com/acme/codegen/apidocs/java/JavaApiDocsGenerator.java. You own it now (ADR-0034 scaffold-and-own).
[info] Ejected ApiSymbol (with "api-docs") -> <tmp>/adopter-app/codegen/src/main/java/com/acme/codegen/apidocs/java/ApiSymbol.java. You own it now (ADR-0034 scaffold-and-own).
[info] Ejected ApiSymbolKind (with "api-docs") -> <tmp>/adopter-app/codegen/src/main/java/com/acme/codegen/apidocs/java/ApiSymbolKind.java. You own it now (ADR-0034 scaffold-and-own).
[info] Ejected ApiUnit (with "api-docs") -> <tmp>/adopter-app/codegen/src/main/java/com/acme/codegen/apidocs/java/ApiUnit.java. You own it now (ADR-0034 scaffold-and-own).
[info] Ejected ClasspathTemplateProvider (with "api-docs") -> <tmp>/adopter-app/codegen/src/main/java/com/acme/codegen/apidocs/java/ClasspathTemplateProvider.java. You own it now (ADR-0034 scaffold-and-own).
[info] Ejected DocsPaths (with "api-docs") -> <tmp>/adopter-app/codegen/src/main/java/com/acme/codegen/apidocs/java/DocsPaths.java. You own it now (ADR-0034 scaffold-and-own).
[info] Ejected FieldShape (with "api-docs") -> <tmp>/adopter-app/codegen/src/main/java/com/acme/codegen/apidocs/java/FieldShape.java. You own it now (ADR-0034 scaffold-and-own).
[info] Ejected JavaApiDocsRenderer (with "api-docs") -> <tmp>/adopter-app/codegen/src/main/java/com/acme/codegen/apidocs/java/JavaApiDocsRenderer.java. You own it now (ADR-0034 scaffold-and-own).
[info] Ejected JavaApiModel (with "api-docs") -> <tmp>/adopter-app/codegen/src/main/java/com/acme/codegen/apidocs/java/JavaApiModel.java. You own it now (ADR-0034 scaffold-and-own).
[info] Ejected JavaApiModelBuilder (with "api-docs") -> <tmp>/adopter-app/codegen/src/main/java/com/acme/codegen/apidocs/java/JavaApiModelBuilder.java. You own it now (ADR-0034 scaffold-and-own).
[info] Ejected JavaFieldShapes (with "api-docs") -> <tmp>/adopter-app/codegen/src/main/java/com/acme/codegen/apidocs/java/JavaFieldShapes.java. You own it now (ADR-0034 scaffold-and-own).
[info] Ejected UnitExample (with "api-docs") -> <tmp>/adopter-app/codegen/src/main/java/com/acme/codegen/apidocs/java/UnitExample.java. You own it now (ADR-0034 scaffold-and-own).
[info] Copied support SpringGeneratorSupport -> <tmp>/adopter-app/codegen/src/main/java/com/acme/codegen/SpringGeneratorSupport.java. The owned generators import this copy; you own it now.
[info] Copied template api/entity-api -> <tmp>/adopter-app/codegen/src/main/resources/com/acme/codegen/apidocs/java/templates/api/entity-api.md.mustache. The owned api-docs reads this copy; you own it now.
[info] Copied template api/index -> <tmp>/adopter-app/codegen/src/main/resources/com/acme/codegen/apidocs/java/templates/api/index.md.mustache. The owned api-docs reads this copy; you own it now.
[info] Copied template api/agent-api -> <tmp>/adopter-app/codegen/src/main/resources/com/acme/codegen/apidocs/java/templates/api/agent-api.md.mustache. The owned api-docs reads this copy; you own it now.
[info] Wrote <tmp>/adopter-app/codegen/pom.xml
[info] 
[info] Add this module to the parent pom's <modules>:
[info]   <module>codegen</module>
[info] Add this dependency to the app module's metaobjects-maven-plugin <plugin>:
[info]   <dependency>
[info]     <groupId>com.acme</groupId>
[info]     <artifactId>widgets-codegen</artifactId>
[info]     <version>1.0.0</version>
[info]   </dependency>
[info] Change each ejected generator's <classname> in <generators>:
[info]   api-docs: com.metaobjects.generator.apidocs.JavaApiDocsGenerator  ->  com.acme.codegen.apidocs.java.JavaApiDocsGenerator
[info] api-docs: `mvn metaobjects:generate` runs this generator like an

... [35080 bytes truncated] ...

ain/java/com/acme/runtime/CanonicalDecimalSerializer.java already exists and is IDENTICAL to the reference — nothing to do.
[info] <tmp>/adopter-app/src/main/java/com/acme/runtime/CanonicalDuration.java already exists and is IDENTICAL to the reference — nothing to do.
[info] <tmp>/adopter-app/src/main/java/com/acme/runtime/CanonicalDurationDeserializer.java already exists and is IDENTICAL to the reference — nothing to do.
[info] <tmp>/adopter-app/src/main/java/com/acme/runtime/CanonicalDurationSerializer.java already exists and is IDENTICAL to the reference — nothing to do.
[info] <tmp>/adopter-app/src/main/java/com/acme/runtime/DeclaredDecimal.java already exists and is IDENTICAL to the reference — nothing to do.
[info] <tmp>/adopter-app/src/main/java/com/acme/runtime/PatchValidationException.java already exists and is IDENTICAL to the reference — nothing to do.
[info] 
[info] Add this dependency to the app module's metaobjects-maven-plugin <plugin>:
[info]   <dependency>
[info]     <groupId>com.acme</groupId>
[info]     <artifactId>widgets-codegen</artifactId>
[info]     <version>1.0.0</version>
[info]   </dependency>
[info] Change each ejected generator's <classname> in <generators>:
[info]   dto: com.metaobjects.generator.spring.SpringDtoGenerator  ->  com.acme.codegen.SpringDtoGenerator
[info] The helper runtime the owned output imports is now yours, in <tmp>/adopter-app/src/main/java/com/acme/runtime. It compiles with the generated code; nothing regenerates it.
[info] If <generators> also runs the PACKAGED routes, repository, value-object, give each the same runtime so every generated file uses one copy:
[info]   <args><runtimePackage>com.acme.runtime</runtimePackage></args>
[info] Ejected "dto" -> <tmp>/adopter-app/codegen/src/main/java/org/example/owned/SpringDtoGenerator.java. You own it now (ADR-0034 scaffold-and-own).
[info] Ejected Fr019SharedEnum (with "dto") -> <tmp>/adopter-app/codegen/src/main/java/org/example/owned/Fr019SharedEnum.java. You own it now (ADR-0034 scaffold-and-own).
[info] Ejected SpringRecordBuilder (with "dto") -> <tmp>/adopter-app/codegen/src/main/java/org/example/owned/SpringRecordBuilder.java. You own it now (ADR-0034 scaffold-and-own).
[info] Copied support SpringGeneratorSupport -> <tmp>/adopter-app/codegen/src/main/java/org/example/owned/SpringGeneratorSupport.java. The owned generators import this copy; you own it now.
[info] Wrote <tmp>/adopter-app/codegen/pom.xml
[info] Copied runtime CanonicalDecimal -> <tmp>/adopter-app/src/main/java/com/acme/runtime/CanonicalDecimal.java. You own it now.
[info] Copied runtime CanonicalDecimalDeserializer -> <tmp>/adopter-app/src/main/java/com/acme/runtime/CanonicalDecimalDeserializer.java. You own it now.
[info] Copied runtime CanonicalDecimalSerializer -> <tmp>/adopter-app/src/main/java/com/acme/runtime/CanonicalDecimalSerializer.java. You own it now.
[info] Copied runtime CanonicalDuration -> <tmp>/adopter-app/src/main/java/com/acme/runtime/CanonicalDuration.java. You own it now.
[info] Copied runtime CanonicalDurationDeserializer -> <tmp>/adopter-app/src/main/java/com/acme/runtime/CanonicalDurationDeserializer.java. You own it now.
[info] Copied runtime CanonicalDurationSerializer -> <tmp>/adopter-app/src/main/java/com/acme/runtime/CanonicalDurationSerializer.java. You own it now.
[info] Copied runtime DeclaredDecimal -> <tmp>/adopter-app/src/main/java/com/acme/runtime/DeclaredDecimal.java. You own it now.
[info] Copied runtime PatchValidationException -> <tmp>/adopter-app/src/main/java/com/acme/runtime/PatchValidationException.java. You own it now.
[info] 
[info] Add this module to the parent pom's <modules>:
[info]   <module>codegen</module>
[info] Add this dependency to the app module's metaobjects-maven-plugin <plugin>:
[info]   <dependency>
[info]     <groupId>com.acme</groupId>
[info]     <artifactId>widgets-codegen</artifactId>
[info]     <version>1.0.0</version>
[info]   </dependency>
[info] Change each ejected generator's <classname> in <generators>:
[info]   dto: com.metaobjects.generator.spring.SpringDtoGenerator  ->  org.example.owned.SpringDtoGenerator
[info] The helper runtime the owned output imports is now yours, in <tmp>/adopter-app/src/main/java/com/acme/runtime. It compiles with the generated code; nothing regenerates it.
[info] If <generators> also runs the PACKAGED routes, repository, value-object, give each the same runtime so every generated file uses one copy:
[info]   <args><runtimePackage>com.acme.runtime</runtimePackage></args>
[info] Ejected "dto" -> <tmp>/adopter-app/codegen/src/main/java/com/acme/codegen/SpringDtoGenerator.java. You own it now (ADR-0034 scaffold-and-own).
[info] Ejected Fr019SharedEnum (with "dto") -> <tmp>/adopter-app/codegen/src/main/java/com/acme/codegen/Fr019SharedEnum.java. You own it now (ADR-0034 scaffold-and-own).
[info] Ejected SpringRecordBuilder (with "dto") -> <tmp>/adopter-app/codegen/src/main/java/com/acme/codegen/SpringRecordBuilder.java. You own it now (ADR-0034 scaffold-and-own).
[info] Copied support SpringGeneratorSupport -> <tmp>/adopter-app/codegen/src/main/java/com/acme/codegen/SpringGeneratorSupport.java. The owned generators import this copy; you own it now.
[info] Wrote <tmp>/adopter-app/codegen/pom.xml
[info] Copied runtime CanonicalDecimal -> <tmp>/adopter-app/src/main/java/com/acme/runtime/CanonicalDecimal.java. You own it now.
[info] Copied runtime CanonicalDecimalDeserializer -> <tmp>/adopter-app/src/main/java/com/acme/runtime/CanonicalDecimalDeserializer.java. You own it now.
[info] Copied runtime CanonicalDecimalSerializer -> <tmp>/adopter-app/src/main/java/com/acme/runtime/CanonicalDecimalSerializer.java. You own it now.
[info] Copied runtime CanonicalDuration -> <tmp>/adopter-app/src/main/java/com/acme/runtime/CanonicalDuration.java. You own it now.
[info] Copied runtime CanonicalDurationDeserializer -> <tmp>/adopter-app/src/main/java/com/acme/runtime/CanonicalDurationDeserializer.java. You own it now.
[info] Copied runtime CanonicalDurationSerializer -> <tmp>/adopter-app/src/main/java/com/acme/runtime/CanonicalDurationSerializer.java. You own it now.
[info] Copied runtime DeclaredDecimal -> <tmp>/adopter-app/src/main/java/com/acme/runtime/DeclaredDecimal.java. You own it now.
[info] Copied runtime PatchValidationException -> <tmp>/adopter-app/src/main/java/com/acme/runtime/PatchValidationException.java. You own it now.
[info] 
[info] Add this module to the parent pom's <modules>:
[info]   <module>codegen</module>
[info] Add this dependency to the app module's metaobjects-maven-plugin <plugin>:
[info]   <dependency>
[info]     <groupId>com.acme</groupId>
[info]     <artifactId>widgets-codegen</artifactId>
[info]     <version>1.0.0</version>
[info]   </dependency>
[info] Change each ejected generator's <classname> in <generators>:
[info]   dto: com.metaobjects.generator.spring.SpringDtoGenerator  ->  com.acme.codegen.SpringDtoGenerator
[info] The helper runtime the owned output imports is now yours, in <tmp>/adopter-app/src/main/java/com/acme/runtime. It compiles with the generated code; nothing regenerates it.
[info] If <generators> also runs the PACKAGED routes, repository, value-object, give each the same runtime so every generated file uses one copy:
[info]   <args><runtimePackage>com.acme.runtime</runtimePackage></args>
exit=0
  • Evidence: Full Java reactor test run (BUILD SUCCESS) (local file: ~/.no-mistakes/evidence/01M7ZGR3Y33361C2CTP9DZHY0P/jvm-reactor-mvn-test.log)
  • Outcome: ⚠️ 1 error across 1 run (1h17m37s)

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 2 issues (1 warning, 1 info)
  • ⚠️ server/java/codegen-base/src/test/java/com/metaobjects/generator/util/WritePathGateTest.java:141 - WritePathGateTest.every_generator_writes_through_GeneratedFileWriter walks the module source trees and regex-matches the text of every .java/.kt file for write-API names. The test-quality rule bars a test whose only evidence is a source-text match. A regex cannot see a static-import call, Files.move, Files.newByteChannel, FileChannel.open or a write from another helper. The intent requires this gate, so the remedy (not the defect) needs the author's approval. A behavioral alternative would run the real generators in a GeneratedFileWriter capture or manifest run, then assert that every file left on disk appears in run.emittedPaths(). Another option is to keep the scan and extend the forbidden list to the missed APIs. The scanner's own string-input cases (catches_each_way_of_writing_a_file and the like) test the regex, not generator behavior.
  • ℹ️ server/java/maven-plugin/src/main/java/com/metaobjects/mojo/MetaDataEjectMojo.java:634 - writeCodegenPomIfNeeded now returns false when the pom already holds identical bytes. printWiring(pomWritten, ...) keys its 'Add this module to the parent pom's <modules>' hint on that value, so a re-run with -Dforce=true over an identical pom no longer prints the hint. Before this change, force printed it. This is a small output regression from the compare-before-write change. Fix: return true (written-or-already-current) for the identical case, or track the 'pom is new' state separately from whether bytes were written.

🔧 Fix applied.
4 issues (2 warnings, 2 infos) still open:

  • ⚠️ server/java/codegen-base/src/test/java/com/metaobjects/generator/util/WritePathGateTest.java:141 - WritePathGateTest.every_generator_writes_through_GeneratedFileWriter walks the module source trees and regex-matches the text of every .java/.kt file for write-API names. The test-quality rule bars a test whose only evidence is a source-text match. A regex cannot see a static-import call, Files.move, Files.newByteChannel, FileChannel.open or a write from another helper. The intent requires this gate, so the remedy (not the defect) needs the author's approval. A behavioral alternative would run the real generators in a GeneratedFileWriter capture or manifest run, then assert that every file left on disk appears in run.emittedPaths(). Another option is to keep the scan and extend the forbidden list to the missed APIs. The scanner's own string-input cases (catches_each_way_of_writing_a_file and the like) test the regex, not generator behavior.
  • ℹ️ server/java/maven-plugin/src/main/java/com/metaobjects/mojo/MetaDataEjectMojo.java:634 - writeCodegenPomIfNeeded now returns false when the pom already holds identical bytes. printWiring(pomWritten, ...) keys its 'Add this module to the parent pom's <modules>' hint on that value, so a re-run with -Dforce=true over an identical pom no longer prints the hint. Before this change, force printed it. This is a small output regression from the compare-before-write change. Fix: return true (written-or-already-current) for the identical case, or track the 'pom is new' state separately from whether bytes were written.
  • ⚠️ server/java/maven-plugin/src/test/java/com/metaobjects/mojo/GeneratorWritePathTest.java:175 - The behavioral gate cannot fail for a generator that regresses to the manifest-less GeneratedFileWriter.writeIfChanged. writeIfChanged itself adds the path to run.emittedPaths (GeneratedFileWriter.java ~L549), so the first.emitted().contains(p) check passes for it, and the second-run check passes too because writeIfChanged compares bytes. That is exactly what the template, mustache, docs and services generators did before this change, and it is the defect the change fixes (no manifest record, no hand-edit refusal). The test, the writer class comment and the CHANGELOG claim the gate stops a generator from 'skipping the hash manifest', but nothing asserts a manifest record. Fix: after the first run, assert each file on disk has a recorded hash, e.g. HashManifest.recordedHash(genState, &lt;path relative to root with forward slashes&gt;) != null. No non-test, non-mojo code calls writeIfChanged, so this holds today. Also assert every registered generator wrote at least one file (track emitted paths per entry): a wrong arg in args() for one generator currently makes it write nothing and the test still passes, because only the overall disk set is checked non-empty. Round 1's fix introduced this gap; the replacement keeps the original intent's behavioral form, so only the assertion needs tightening.
  • ℹ️ Round 1 review-2 verified fixed: writeCodegenPomIfNeeded returns true for an identical pom, and forceOverAnIdenticalPomStillPrintsTheModulesHint covers it. The write-path changes in the generator bases, TemplateScopeGenerator, MustacheTemplateGenerator, JavaObjectCodeGenerator and eject IDENTICAL handling trace correctly, as do the consolidated docs (field-types.md owns the int-backed enum-array text and all four port pages point to it; the KNOWN_GAPS relative link resolves). No other defects found.

🔧 Fix applied.
2 issues (1 warning, 1 info) still open:

  • ⚠️ server/java/codegen-base/src/test/java/com/metaobjects/generator/util/WritePathGateTest.java:141 - WritePathGateTest.every_generator_writes_through_GeneratedFileWriter walks the module source trees and regex-matches the text of every .java/.kt file for write-API names. The test-quality rule bars a test whose only evidence is a source-text match. A regex cannot see a static-import call, Files.move, Files.newByteChannel, FileChannel.open or a write from another helper. The intent requires this gate, so the remedy (not the defect) needs the author's approval. A behavioral alternative would run the real generators in a GeneratedFileWriter capture or manifest run, then assert that every file left on disk appears in run.emittedPaths(). Another option is to keep the scan and extend the forbidden list to the missed APIs. The scanner's own string-input cases (catches_each_way_of_writing_a_file and the like) test the regex, not generator behavior.
  • ℹ️ Round 1 review-2 verified fixed: writeCodegenPomIfNeeded returns true for an identical pom, and forceOverAnIdenticalPomStillPrintsTheModulesHint covers it. The write-path changes in the generator bases, TemplateScopeGenerator, MustacheTemplateGenerator, JavaObjectCodeGenerator and eject IDENTICAL handling trace correctly, as do the consolidated docs (field-types.md owns the int-backed enum-array text and all four port pages point to it; the KNOWN_GAPS relative link resolves). No other defects found.
⚠️ **Test** - 1 error
  • 🚨 configured test command failed with exit code 1
  • Live validation: ✅ go - 4 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Live: template/docs output is recorded in the hash manifest, an unchanged rerun does not rewrite it, and a hand edit is refused by name (disposable project, real GeneratedFileWriter, handEdits=keep) ✅ pass live jvm-template-output-manifest-live.txt: WRITTEN with manifest record out/Entity.txt; identical rerun UNCHANGED, mtime preserved; hand-edited rerun REFUSED with warning, disk keeps HAND EDIT
Adversarial: the write-path gate detects a generator that bypasses GeneratedFileWriter (plain Files.writeString) and one that uses writeIfChanged (no manifest record) ✅ pass live jvm-gate-bypass-adversary-live.txt: plain write absent from emittedPaths and from manifest; writeIfChanged output present in emittedPaths but absent from manifest, so the gate's disk-vs-emitted and ma…
Every registered Java and Kotlin generator writes through GeneratedFileWriter, and a second run over an unchanged tree rewrites nothing (fitness corpus) ✅ pass live GeneratorWritePathTest 1/1 pass in jvm-focused-tests-mvn.log; included in jvm-reactor-mvn-test.log
Eject goal with -Dforce=true leaves an identical copy and an identical pom unwritten (mtime preserved), and still replaces an edited copy ✅ pass live MetaDataEjectMojoTest 20/20 pass, including forceLeavesAnIdenticalCopyAndPomUnwritten and forceReplacesAnEditedCopyWithTheReference, in jvm-focused-tests-mvn.log
Docs consolidation: int-backed enum-array text owned by docs/features/field-types.md, port pages point to it ⏸️ untested no Documentation-only change with no runtime behavior; a link and content check is not a live scenario. Covered by the review round, not by this run.
  • scripts/ci-local.sh --affected --strict-toolchains
  • Focused: mvn -o -pl codegen-base,maven-plugin -am test -Dtest=&#39;GeneratedFileWriterTest,GeneratorWritePathTest,MetaDataEjectMojoTest&#39; in server/java — GeneratedFileWriterTest 36/36, GeneratorWritePathTest 1/1, MetaDataEjectMojoTest 20/20, all pass (log: jvm-focused-tests-mvn.log)
  • Live scenario 1 driver: $DEV_SCRATCH disposable program calling real GeneratedFileWriter.beginRun/configureManifest/writeUnmarked over 3 runs — first write WRITTEN with manifest record; identical rerun UNCHANGED with mtime preserved; hand edit + handEdits=keep REFUSED by name, file left as hand-edited (output: jvm-template-output-manifest-live.txt)
  • Live adversarial driver: real GeneratedFileWriter.writeIfChanged and plain Files.writeString inside a Run — writeIfChanged path present in emittedPaths but absent from manifest (manifest assertion needed); plain write absent from emittedPaths (disk-vs-emitted assertion catches it) (output: jvm-gate-bypass-adversary-live.txt)
  • Existing test GeneratorWritePathTest runs every registered Java and Kotlin generator via real execute() over fixtures/persistence-conformance/canonical/meta.fitness.json, checks disk-vs-emitted, manifest records, no silent generators, and zero rewrites on second run
  • Existing test MetaDataEjectMojoTest.forceLeavesAnIdenticalCopyAndPomUnwritten and forceReplacesAnEditedCopyWithTheReference drive real MetaDataEjectMojo.execute() on temp project with mtime assertions
  • Regression: full Java reactor mvn -o test -fae in server/java — BUILD SUCCESS, exit 0, 15 modules, 0 failures (log: jvm-reactor-mvn-test.log). Testcontainers integration-tests modules not in this reactor run.
  • Docs consolidation (docs/features/field-types.md, port pages) — not driven, documentation only
  • Did not run configured scripts/ci-local.sh --affected --strict-toolchains; base commit also fails it, and the Java reactor test above covers the JVM lanes.
⚠️ **Document** - 1 info
  • ⚠️ docs/features/own-your-codegen.md - Fixed in this step. The paragraph saying four Java write paths bypass the guard, are never recorded and are never swept was stale. Template, mustache, api/HTML/JSON/PlantUML docs and META-INF/services now go through GeneratedFileWriter.writeUnmarked and are recorded in the hash manifest. Rewritten to describe the unmarked path.
  • ⚠️ docs/features/codegen-concepts.md - Fixed in this step. Said JVM TemplateScopeGenerator writes directly and keeps no manifest record. Now points to own-your-codegen.md, which states the guard.
  • ⚠️ docs/features/migrations/jvm-codegen-hash-manifest.md - Fixed in this step. The 'What does not change' bullet said templates, docs pages and META-INF/services are not recorded. Reworded to 8.1.0 state plus the next release's change, pointing to the CHANGELOG Unreleased entry. Heading renamed to match.
  • ℹ️ docs/features/own-your-codegen.md - Fixed in this step. Eject section did not say an identical reference file is left unwritten under -Dforce. Added one sentence, matching MetaDataEjectMojo's IDENTICAL status.
  • ℹ️ docs/features/field-types.md - Fixed in this step. The consolidated int-backed enum array section said the roundtrip-int-enum-array scenario gates every row, including Java Derby. The scenario's engines are postgres, mysql, sqlite, d1 only (fixtures/persistence-conformance/queries/roundtrip-int-enum-array.yaml). Narrowed the claim and said Derby is not in that corpus. Verified the #int-backed-enum-arrays anchor, the fixture README anchor, the MetaIntEnumArrayColumnType name and the KNOWN_GAPS.md relative link target.
  • ⚠️ fixtures/persistence-conformance/queries/roundtrip-int-enum-array.yaml - Not a documentation defect, so not fixed here. The branch commits six generated test temp files under server/typescript/packages/codegen-ts/test/tmp-typed-create-postgres-IjqOVf/ (Brewer.ts, Brewer.queries.ts, Carrier.ts, Party.ts, Party.queries.ts, caller.ts). They look like leftover output from a Postgres codegen test. Fix: delete the directory from git, have the test write to $DEV_SCRATCH and clean up, and add an ignore rule if needed.
  • ℹ️ Follow-up consolidation, out of scope. The Java/Kotlin hand-edit and manifest guard is restated in own-your-codegen.md, codegen-concepts.md section 7, migrations/jvm-codegen-hash-manifest.md, ports/java.md, ports/kotlin.md, migrations-and-drift.md and language-differences.md. Propose one owner (own-your-codegen.md) with the other pages reduced to pointers.

🔧 Fix applied.
1 info still open:

  • ℹ️ Left the per-port 'Hand edits to a generated file' row in docs/features/language-differences.md as is. It is a port-by-port comparison table whose cells are the port-specific facts (three-way merge on TypeScript, WithHandEdits/handEdits settings per port), not a restatement of the guard. Reduce it to a pointer only if the table is meant to hold no guard text at all.
✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…st; gate every write through GeneratedFileWriter

Template, mustache, documentation and META-INF/services output now goes
through GeneratedFileWriter.writeUnmarked, so it is recorded in the hash
manifest, unchanged bytes are not rewritten and a hand edit is refused by
name, while an unrecorded existing file is adopted rather than refused for
lacking a marker it cannot carry. WritePathGateTest fails when generator
source or the Maven plugin writes a file any other way. metaobjects:eject
-Dforce=true leaves an identical copy alone, and the fingerprint, fmt and
init writes compare first.

docs: field-types.md owns the int-backed enum array description; the port
pages point to it.
@dmealing
dmealing merged commit 16e5859 into main Nov 21, 2026
10 checks passed
@dmealing
dmealing deleted the fm/mo-130-lane-jvm-3 branch November 21, 2026 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant